#coding=utf-8
import re
import requests,json,urllib
import urllib
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )


def getphotos(url):
    s = requests.session()
    print u'开始爬取图片'
    index = s.get(url)
    #print index.text
    #通过正则取出所有的src连接
    photo = re.findall(r'data-original="(.+?\.jpg)"', index.text)
    print photo
    x = 0
    #try:
    for photo1 in photo:
        photo1 = str(photo1).replace('//', 'http://')
        print photo1
        urllib.urlretrieve(photo1, 'D:\\images\\photo_yashua\\%s.jpg' % x)
        x = x + 1
        print x
    #except:
        #print u'异常'


if __name__ =='__main__':
    getphotos('http://z.jd.com/project/details/105285.html')